package com.project.server.controller;

import com.project.server.common.exception.BusinessException;
import com.project.server.utils.JwtUtil;
import jakarta.servlet.http.HttpServletRequest;

public abstract class BaseController {
    
    /**
     * 获取当前登录用户ID
     */
    protected Long getCurrentUserId(HttpServletRequest request) {
        Long userId = JwtUtil.getUserIdFromRequest(request);
        if (userId == null) {
            throw new BusinessException("未登录或token已过期");
        }
        return userId;
    }
} 
